# Replication Package: Demographic Divergence and Safe Asset Scarcity

## Overview

This replication package reproduces all results in "Demographic Divergence and Safe Asset Scarcity."

## Requirements

- Python 3.8+
- pandas, numpy, scipy, statsmodels
- python-docx (for document generation)
- matplotlib (for figures)

## Directory Structure

```
replication/
├── scripts/          # Analysis scripts (phase1-6 + build_docx.py)
├── src/              # Shared estimation code (PanelGLS)
├── data/             # Processed panel data
├── output/           # Generated tables and figures
├── paper/            # Paper markdown and docx
└── README.md         # This file
```

## Reproduction Steps

1. Ensure `src/model.py` is present (PanelGLS estimator)
2. Run scripts in order:
   ```
   python scripts/phase1_data_assembly.py
   python scripts/phase2_rate_decomposition.py
   python scripts/phase3_portfolio_allocation.py
   python scripts/phase4_supply_demand.py
   python scripts/phase5_bilateral_gravity.py
   python scripts/phase6_projections.py
   python scripts/build_docx.py
   ```
3. Output tables will be in `output/tables/`
4. Figure will be in `output/figures/`
5. Paper docx will be in `paper/`

## Data Sources

- UN World Population Prospects 2024 (demographics)
- IMF IFS (bond yields, short rates)
- Lane–Milesi-Ferretti External Wealth of Nations (gross positions)
- IMF CPIS (bilateral portfolio positions)
- S&P sovereign ratings via Kose et al. (World Bank)
- IMF WEO (fiscal variables)
- CEPII GeoDist (gravity variables)

## Key Results

- Table 2: Rate decomposition — Z₁ ≈ 43.7** on 10y bonds, concentrates among safe issuers
- Table 3: Portfolio allocation — aging → debt tilt, safe share
- Table 5: Bilateral gravity — safe-seeking (dZ×dest_safe) significant for debt, null for equity
- Figure 1: Safe asset gap widening through 2050
